package com.wdl.modules.myhouse.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wdl.modules.myhouse.dao.UploadLogDao;
import com.wdl.modules.myhouse.entity.UploadLogEntity;
import com.wdl.modules.myhouse.service.UploadLogService;
import com.wdl.modules.myhouse.vo.UploadApprovalVo;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * 上传记录表
 *
 * @author lucain sunlightcs@gmail.com
 * @since 1.0.0 2022-10-08
 */
@Service
public class UploadLogServiceImpl extends ServiceImpl<UploadLogDao, UploadLogEntity> implements UploadLogService {


    @Override
    public IPage<UploadApprovalVo> getUploadLogAndOtherInfo(IPage<UploadLogEntity> iPage) {
        long current = iPage.getCurrent();
        long size = iPage.getSize();
        List<UploadApprovalVo> records = this.baseMapper.selectAllAboutMessByUploadLog(current - 1, size);
        int total = this.list().size();

        Page<UploadApprovalVo> page = new Page<>();
        page.setSize(size);
        page.setCurrent(current);
        page.setRecords(records);
        page.setTotal(total);
        page.setPages(total % size == 0 ? total / size : total / size + 1);
        return page;
    }
}